
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>flutter · Aivin开发笔记</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="Aivin">
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search-plus/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-anchor-navigation-ex/style/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-tbfed-pagefooter/footer.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-donate/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-local-video/video-js.min.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-splitter/splitter.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-theme-comscore/test.css">
                
            
        

    

    
        
        <link rel="stylesheet" href="../styles/website.css">
        
    

        
    
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="flutter控件.html" />
    
    
    <link rel="prev" href="flutter配置.html" />
    

    
        <link rel="shortcut icon" href='../assets/images/favicon.ico' type="image/x-icon">
    
    
        <link rel="bookmark" href='../assets/images/favicon.ico' type="image/x-icon">
    
    
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    个人信息
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="flutter配置.html">
            
                <a href="flutter配置.html">
            
                    
                    flutter配置
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.3" data-path="flutter语法.html">
            
                <a href="flutter语法.html">
            
                    
                    flutter
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="flutter控件.html">
            
                <a href="flutter控件.html">
            
                    
                    flutter控件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="flutter第三方库.html">
            
                <a href="flutter第三方库.html">
            
                    
                    flutter第三方库
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="flutter异常.html">
            
                <a href="flutter异常.html">
            
                    
                    flutter异常
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >flutter</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div class="search-plus" id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <div id="anchor-navigation-ex-navbar"><i class="fa fa-navicon"></i><ul><li><span class="title-icon "></span><a href="#flutter"><b>1. </b>flutter</a></li><ul><li><span class="title-icon "></span><a href="#dart-&#x8BED;&#x6CD5;"><b>1.1. </b>dart &#x8BED;&#x6CD5;</a></li><li><span class="title-icon "></span><a href="#&#x6CE8;&#x89E3;"><b>1.2. </b>&#x6CE8;&#x89E3;</a></li></ul></ul></div><a href="#flutter" id="anchorNavigationExGoTop"><i class="fa fa-arrow-up"></i></a><h1 id="flutter"><a name="flutter" class="anchor-navigation-ex-anchor" href="#flutter"><i class="fa fa-link" aria-hidden="true"></i></a>1. flutter</h1>
<h2 id="dart-&#x8BED;&#x6CD5;"><a name="dart-&#x8BED;&#x6CD5;" class="anchor-navigation-ex-anchor" href="#dart-&#x8BED;&#x6CD5;"><i class="fa fa-link" aria-hidden="true"></i></a>1.1. dart &#x8BED;&#x6CD5;</h2>
<pre><code class="lang-text">dart &#x6587;&#x4EF6;&#x540D;&#x548C;&#x7C7B;&#x540D; &#x53EF;&#x4EE5;&#x4E0D;&#x4E00;&#x6837;  &#x3002;&#x8FD9;&#x70B9;&#x8DDF;Java&#x4E0D;&#x4E00;&#x6837;&#x3002;

&#x5728;&#x53D8;&#x91CF;&#x4E2D;&#x53EF;&#x4EE5;&#x653E;&#x7F6E;&#x7684;&#x6240;&#x6709;&#x4E1C;&#x897F;&#x90FD;&#x662F;&#x5BF9;&#x8C61;&#xFF0C;&#x800C;&#x6BCF;&#x4E2A;&#x5BF9;&#x8C61;&#x90FD;&#x662F;&#x7C7B;&#x7684;&#x5B9E;&#x4F8B;&#x3002;&#x65E0;&#x8BBA;&#x6570;&#x5B57;&#x3001;&#x51FD;&#x6570;&#x548C;null&#x90FD;&#x662F;&#x5BF9;&#x8C61;&#x3002;

&#x5982;&#x679C;&#x8981;&#x660E;&#x786E;&#x8BF4;&#x660E;&#x4E0D;&#x9700;&#x8981;&#x4EFB;&#x4F55;&#x7C7B;&#x578B;&#xFF0C;&#x8BF7;&#x4F7F;&#x7528;[&#x7279;&#x6B8A;&#x7C7B;&#x578B;dynamic]&#x3002;

// &#x53EF;&#x89C1;&#x6027; &#xFF0C;public private &#x8DDF;Java&#x4E0D;&#x4E00;&#x6837;
Dart&#x6CA1;&#x6709;&#x516C;&#x5F00;&#x3001;&#x4FDD;&#x62A4;&#x548C;&#x79C1;&#x6709;&#x7684;&#x5173;&#x952E;&#x5B57;&#x3002;&#x5982;&#x679C;&#x6807;&#x8BC6;&#x7B26;&#x4EE5;&#x4E0B;&#x5212;&#x7EBF;(_)&#x5F00;&#x5934;&#xFF0C;&#x5219;&#x8BE5;&#x6807;&#x8BC6;&#x7B26;&#x5BF9;&#x5176;&#x5E93;&#x662F;&#x79C1;&#x6709;&#x7684;&#x3002;


&#x672A;&#x521D;&#x59CB;&#x5316;&#x7684;&#x53D8;&#x91CF;&#x7684;&#x521D;&#x59CB;&#x503C;&#x4E3A;null&#x3002;&#x751A;&#x81F3;&#x5177;&#x6709;&#x6570;&#x5B57;&#x7C7B;&#x578B;&#x7684;&#x53D8;&#x91CF;&#x6700;&#x521D;&#x4E5F;&#x662F;null&#xFF0C;&#x56E0;&#x4E3A;&#x6570;&#x5B57;&#xFF0C;&#x5C31;&#x50CF;dart&#x4E2D;&#x7684;&#x5176;&#x4ED6;&#x4E1C;&#x897F;&#x4E00;&#x6837;&#x4E5F;&#x662F;&#x5BF9;&#x8C61;&#x3002;
int lineCount;
assert(lineCount == null);
&#x6CE8;&#x610F;:&#x5728;&#x751F;&#x4EA7;&#x73AF;&#x5883;&#x4E2D;&#xFF0C;assert()&#x8C03;&#x7528;&#x88AB;&#x5FFD;&#x7565;&#x3002;&#x5728;&#x5F00;&#x53D1;&#x73AF;&#x5883;&#x4E2D;&#x5F53;assert(condition) &#x7684;condition&#x6761;&#x4EF6;&#x4E0D;&#x4E3A;&#x771F;&#x65F6;&#x629B;&#x51FA;&#x4E00;&#x4E2A;&#x5F02;&#x5E38;&#x3002;

final&#x548C;const&#x533A;&#x522B; &#xFF1A;
const&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x5176;&#x4ED6;const&#x5E38;&#x91CF;&#x7684;&#x503C;&#x6765;&#x521D;&#x59CB;&#x5316;&#x5176;&#x503C;&#x3002;
final dt = DateTime.now();//&#x6B63;&#x786E;&#xFF0C;&#x8FD0;&#x884C;&#x65F6;&#x6709;&#x786E;&#x5B9A;&#x7684;&#x503C;
const dt = const DateTime.now();//&#x9519;&#x8BEF;&#xFF0C;&#x9700;&#x8981;&#x7F16;&#x8BD1;&#x65F6;&#x6709;&#x786E;&#x5B9A;&#x7684;&#x503C;
// &#x521D;&#x59CB;&#x5316;&#x540E;&#x4E0D;&#x80FD;&#x518D;&#x8D4B;&#x503C;
final a = &apos;aaa&apos;;
a =  &apos;abc&apos;; //&#x9519;&#x8BEF;
const b = &apos;bbb&apos;;
b =  &apos;abc&apos;; //&#x9519;&#x8BEF;
//&#x4E0D;&#x80FD;&#x548C;var&#x540C;&#x65F6;&#x4F7F;&#x7528;
final var d = &apos;abc&apos;;//&#x9519;&#x8BEF;
const var e = &apos;abc&apos;;//&#x9519;&#x8BEF;

// &#x6570;&#x5B57;&#x7C7B;&#x578B; &#x53EA;&#x6709; int &#x548C; double
var one = int.parse(&apos;1&apos;);
var msg = 3.156.toString() ;
var msg2 = 3.156.toStringAsFixed(2);


// &#x7528; &#x7B49;&#x53F7; == &#x6765;&#x5224;&#x65AD;&#x5BF9;&#x8C61;&#x662F;&#x5426;&#x76F8;&#x7B49;&#xFF0C;&#x8DDF;Java&#x4E0D;&#x592A;&#x4E00;&#x6837;&#x3002;
var msg1 =&quot;abc1&quot; ;
var msg2 =&quot;abc&quot;+&quot;1&quot; ;
print(msg1==msg2) ;  // true

//  &#x7528;r&#x524D;&#x7F00;&#x521B;&#x5EFA;&#x4E00;&#x4E2A;&#x539F;&#x59CB;&#x5B57;&#x7B26;&#x4E32; (&#x5373; &#x8F6C;&#x4E49;&#x5B57;&#x7B26;&#x6CA1;&#x6709;&#x88AB;&#x8F6C;&#x4E49;)
var msg1 = r&apos;In a raw string, not even \n gets special treatment.&apos;;

// &#x591A;&#x884C;&#x5B57;&#x7B26;&#x4E32; &#xFF0C;&#x7528; + &#x8FDE;&#x63A5; &#xFF0C;&#x6216;&#x8005;&#x662F; &#x5E26;&#x6709;&#x5355;&#x5F15;&#x53F7;&#x6216;&#x53CC;&#x5F15;&#x53F7;&#x7684;&#x4E09;&#x91CD;&#x5F15;&#x53F7;
var msg1 =
  &apos;&apos;&apos;1111
  222222
  33333
  &apos;&apos;&apos;;

 var list = [1, 2, 3];  // &#x53EF;&#x53D8;&#x5217;&#x8868;&#x3001;&#x6570;&#x7EC4;
  var list2 = const [1, 2, 3]; // &#x5E38;&#x91CF;&#x5217;&#x8868;



 = &gt;expr &#x8BED;&#x6CD5;&#x662F;{return expr;}&#x7684;&#x7B80;&#x5199;&#x5199;&#x6CD5;&#x3002;&#x201C;=&gt;&#x201D;&#x7B26;&#x53F7;&#x6709;&#x65F6;&#x88AB;&#x79F0;&#x4E3A;&#x80D6;&#x7BAD;&#x5934;&#x8BED;&#x6CD5;&#x3002;

// &#x547D;&#x540D;&#x51FD;&#x6570; &#xFF0C;&#x53EF;&#x4EE5;&#x5E26;&#x6709;&#x9ED8;&#x8BA4;&#x503C;
void enableFlags( { int age =18, String myName } ) {
  print( &quot;age=$age ,name=$myName&quot;) ; // age=20 ,name=aivin
}
 // age &#x548C; myName &#x5728;&#x51FD;&#x6570;&#x4E2D;&#x5DF2;&#x7ECF;&#x5B9A;&#x4E49;&#x4E86;&#xFF0C;&#x76F8;&#x5F53;&#x4E8E;&#x76F4;&#x63A5;&#x521D;&#x59CB;&#x5316;&#xFF0C;&#x6B64;&#x5904; age &#x4E0D;&#x80FD;&#x5199;&#x6210;&#x5176;&#x4ED6; age1&#x7B49;
 enableFlags( age: 20, myName: &quot;aivin&quot;);

// &#x4F4D;&#x7F6E;&#x53C2;&#x6570;
void  say(String from, String msg, [ int time]) {
  var result = &apos;$from says $msg $time&apos;; // aivin says &#x73B0;&#x5728;&#x65F6;&#x95F4;&#x662F;: null
  print(result) ;
}
say(&apos;aivin&apos; ,&apos;&#x73B0;&#x5728;&#x65F6;&#x95F4;&#x662F;:&apos;   ) ;

// &#x7EA7;&#x8054;&#x64CD;&#x4F5C;&#x7B26; &#xFF0C;&#x8DDF;Java&#x7684;&#x94FE;&#x5F0F;&#x8C03;&#x7528;&#x5DEE;&#x4E0D;&#x591A;
  Address address =   Address();
  address  ..street = &apos;&#x5317;&#x4EAC;&#x5E02;&apos;
    ..number = &apos;12&apos;
    ..name = &apos;&#x897F;&#x57CE;&#x533A;&apos;

 &#x6240;&#x6709;&#x51FD;&#x6570;&#x90FD;&#x8FD4;&#x56DE;&#x4E00;&#x4E2A;&#x503C;&#x3002;&#x5982;&#x679C;&#x6CA1;&#x6709;&#x6307;&#x5B9A;&#x8FD4;&#x56DE;&#x503C;&#xFF0C;&#x5219;&#x8BED;&#x53E5;&#x8FD4;&#x56DE;null;&#x9690;&#x5F0F;&#x9644;&#x52A0;&#x5230;&#x51FD;&#x6570;&#x4F53;&#x3002;

//  &#x533F;&#x540D;&#x51FD;&#x6570;
Function showMsg = (int x, String y) {
  print(&quot;$x &quot;);
};

// &#x95ED;&#x5305;
//  java &#x95ED;&#x5305; &#xFF0C;&#x7528;&#x63A5;&#x53E3; &#x548C;&#x533F;&#x540D;&#x51FD;&#x6570; &#x5B9E;&#x73B0;&#x3002;-- &#x6240;&#x8C13;&#x95ED;&#x5305;&#x4ECE;&#x8868;&#x9762;&#x770B;&#x5C31;&#x662F;&#x8FD4;&#x56DE;&#x4E00;&#x4E2A; &#x51FD;&#x6570;
    interface  AaddFunc{
        int addBy(int value);
    }

    public static  AaddFunc createNewFunction(final int value){
        return  new AaddFunc() {
            @Override
            public int addBy(int addBy) {
                return value + addBy;
            }
        }  ;
    }

AaddFunc func =  createNewFunction(1) ;
 int result =func.addBy(10) ;

// dart &#x95ED;&#x5305;
Function makeAdder( int addBy) {
  return (int value)  {
    return addBy + value;
  } ;
}

var func1 = makeAdder(10);
 var result =func1(1); //11

// dart &#x652F;&#x6301;&#x4E09;&#x76EE;&#x8FD0;&#x7B97;&#x7B26;&#x3002; &#x53C2;&#x8003;Java

if (emp is Person)  // &#x7C7B;&#x578B;&#x5224;&#x65AD; is
(emp as Person) // &#x7C7B;&#x578B;&#x8F6C;&#x6362;  as


b ??= value;   // &#x4EC5;&#x4EC5;&#x5728;b&#x4E3A;&#x7A7A;&#x7684;&#x60C5;&#x51B5;&#x4E0B;b&#x88AB;&#x8D4B;&#x503C;value &#xFF0C;&#x5426;&#x5219;b&#x7684;&#x503C;&#x4E0D;&#x53D8;
print(person ?.name)  //  person &#x4E3A;&#x7A7A; &#x5C31;&#x76F4;&#x63A5;&#x8FD4;&#x56DE;null &#xFF0C;&#x4E0D;&#x4E3A;&#x7A7A; &#x5C31;&#x8FD4;&#x56DE; name&#x7684;&#x503C;


&#x5728;Dart2&#x4E2D;new&#x5173;&#x952E;&#x5B57;&#x662F;&#x53EF;&#x9009;&#x7684;&#x3002; &#x5373; new &#x5173;&#x952E;&#x5B57;&#x53EF;&#x5199;&#x53EF;&#x4E0D;&#x5199;&#x3002;
Dart&#x662F;&#x4E00;&#x79CD;&#x771F;&#x6B63;&#x7684;&#x9762;&#x5411;&#x5BF9;&#x8C61;&#x8BED;&#x8A00;&#xFF0C;&#x6240;&#x4EE5;&#x5373;&#x4F7F;&#x51FD;&#x6570;&#x4E5F;&#x662F;&#x5BF9;&#x8C61;&#x3002;

// mixin  &#x7279;&#x6027; &#xFF08;&#x6CE8;&#x610F; mixin  &#x5E76;&#x4E0D;&#x662F;&#x4E00;&#x4E2A;&#x5173;&#x952E;&#x5B57;&#xFF0C;&#x53EA;&#x662F;&#x4E00;&#x4E2A;&#x666E;&#x901A;&#x7684;&#x5355;&#x8BCD;&#xFF0C;&#x610F;&#x601D;&#x662F;&#x6DF7;&#x5408;&#xFF09;
Dart&#x4E2D;&#xFF0C;&#x6BCF;&#x4E2A;&#x7C7B;&#xFF08;&#x9664;&#x4E86;Object&#x7C7B;&#xFF09;&#x90FD;&#x53EA;&#x6709;&#x4E00;&#x4E2A;&#x8D85;&#x7C7B;&#x3002;&#x4F46;&#x662F;&#x6211;&#x4EEC;&#x6709;&#x65F6;&#x9700;&#x8981;&#x591A;&#x4E2A;&#x7236;&#x7C7B;&#x7684;&#x7279;&#x6027;&#xFF0C;&#x53EF;&#x4EE5;&#x7528; with  &#x6765;&#x5B9E;&#x73B0; minxin &#x7279;&#x6027;&#x3002;
class Walker {
  void walk() {
    print(&quot;I&apos;m walking&quot;);
  }
}
class Fish {
  void swim() {
    print(&quot;I&apos;m swimming&quot;);
  }
}

/**
    Person person = Person() ;
    person.walk() ;
    person.swim() ;
 */
class Person with Walker , Fish  { }


// &#x5F02;&#x6B65;&#x51FD;&#x6570;  async  await
Dart&#x662F;&#x5355;&#x7EBF;&#x7A0B;&#x7684;&#x8BED;&#x8A00;&#xFF0C; &#x5728;Dart1.9&#x4E2D;&#x52A0;&#x5165;&#x4E86;async&#x548C;await&#x5173;&#x952E;&#x5B57;&#xFF0C;&#x6709;&#x4E86;&#x8FD9;&#x4E24;&#x4E2A;&#x5173;&#x952E;&#x5B57;&#xFF0C;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x66F4;&#x7B80;&#x6D01;&#x7684;&#x7F16;&#x5199;&#x5F02;&#x6B65;&#x4EE3;&#x7801;&#xFF0C;&#x800C;&#x4E0D;&#x9700;&#x8981;&#x8C03;&#x7528;Future&#x76F8;&#x5173;&#x7684;API&#xFF08;&#x8FD9;&#x79CD;&#x65B9;&#x6CD5;&#x76F8;&#x5BF9;&#x7E41;&#x7410;&#xFF09;&#x3002;
&#x7528;async&#x6807;&#x8BB0;&#xFF0C;&#x8868;&#x793A;&#x51FD;&#x6570;&#x5185;&#x90E8;&#x5305;&#x542B;&#x6709;&#x9700;&#x8981;&#x5EF6;&#x8FDF;&#x6267;&#x884C;&#x7684;&#x4EE3;&#x7801;&#x3002;
&#x6709;await&#x6807;&#x8BB0;&#x7684;&#x8FD0;&#x7B97;&#xFF0C;&#x5176;&#x7ED3;&#x679C;&#x503C;&#x90FD;&#x662F;&#x4E00;&#x4E2A;Future&#x5BF9;&#x8C61; &#xFF08;&#x9A6C;&#x4E0A;&#x8FD4;&#x56DE;&#xFF09;&#x3002;
// &#x4E3E;&#x4E2A;&#x4F8B;&#x5B50; &#x5C31;&#x4F1A;&#x660E;&#x767D;
func(String callType) async {
  print(&apos;$callType =  &#x65B9;&#x6CD5;&#x5185;&#x90E8;  await &#x8BED;&#x53E5;&#x4E4B;&#x524D;  &apos;);
  await print(&apos;$callType  = await &#x6267;&#x884C;&#x7684;&#x8BED;&#x53E5;  &apos;);
  print(&apos;$callType =  &#x65B9;&#x6CD5;&#x5185;&#x90E8;  await &#x8BED;&#x53E5;&#x4E4B;&#x540E; &apos;);
}

/*
1 &#x65B9;&#x6CD5; &#x901A;&#x8FC7; awiat &#x8C03;&#x7528; =  &#x65B9;&#x6CD5;&#x5185;&#x90E8;  await &#x8BED;&#x53E5;&#x4E4B;&#x524D;
1 &#x65B9;&#x6CD5; &#x901A;&#x8FC7; awiat &#x8C03;&#x7528;  = await &#x6267;&#x884C;&#x7684;&#x8BED;&#x53E5;
1 &#x65B9;&#x6CD5; &#x901A;&#x8FC7; awiat &#x8C03;&#x7528; =  &#x65B9;&#x6CD5;&#x5185;&#x90E8;  await &#x8BED;&#x53E5;&#x4E4B;&#x540E;
1 ---------------------------
2 &#x65B9;&#x6CD5;&#x76F4;&#x63A5;&#x8C03;&#x7528; =  &#x65B9;&#x6CD5;&#x5185;&#x90E8;  await &#x8BED;&#x53E5;&#x4E4B;&#x524D;
2 &#x65B9;&#x6CD5;&#x76F4;&#x63A5;&#x8C03;&#x7528;  = await &#x6267;&#x884C;&#x7684;&#x8BED;&#x53E5;
2 ----------------------------
2 &#x65B9;&#x6CD5;&#x76F4;&#x63A5;&#x8C03;&#x7528; =  &#x65B9;&#x6CD5;&#x5185;&#x90E8;  await &#x8BED;&#x53E5;&#x4E4B;&#x540E;
 */
main( ) async {
  // await &#x65B9;&#x5F0F;&#x8C03;&#x7528;&#x5F02;&#x6B65;&#x65B9;&#x6CD5; , &#x5219;&#x4F1A;&#x7B49;&#x5F02;&#x6B65;&#x65B9;&#x6CD5;&#x6267;&#x884C;&#x5B8C;&#x6210;&#x540E;&#x518D;&#x6267;&#x884C;&#x540E;&#x7EED;&#x7684;&#x4EE3;&#x7801;
  await func(&apos;1 &#x65B9;&#x6CD5; &#x901A;&#x8FC7; awiat &#x8C03;&#x7528;&apos;);
  print(&apos;1 ---------------------------&apos;);
  // &#x6CA1;&#x6709;&#x4F7F;&#x7528; await &#x65B9;&#x5F0F;&#x8C03;&#x7528;&#x5F02;&#x6B65;&#x65B9;&#x6CD5;&#xFF0C;&#x5219;&#x5F02;&#x6B65;&#x65B9;&#x6CD5;&#x6267;&#x884C;&#x5230; await &#x5904;&#x540E;&#x7B49;&#x5F85; ( await&#x6240;&#x5728;&#x7684;&#x8BED;&#x53E5;&#x4F1A;&#x8C03;&#x7528;&#xFF0C;&#x662F;&#x5728;&#x7B49;&#x5F85;&#x8FD4;&#x56DE;&#x7ED3;&#x679C;)&#xFF0C;&#x7A0B;&#x5E8F;&#x7EE7;&#x7EED;&#x6267;&#x884C;&#x5F02;&#x6B65;&#x65B9;&#x6CD5;&#x5916;&#x7684;&#x540E;&#x7EED;&#x4EE3;&#x7801;
  func(&apos;2 &#x65B9;&#x6CD5;&#x76F4;&#x63A5;&#x8C03;&#x7528;&apos;);
  print(&apos;2 ----------------------------&apos;);
}

// &#x751F;&#x6210;&#x5668;
// &#x540C;&#x6B65;&#x751F;&#x6210;&#x5668;  Iterable &#x3001; sync* &#x3001;yield
Iterable&lt;int&gt; getSyncGenerator(int n ) sync* {
  int k = n;
  while (k &gt; 0) {
    yield k--;
  }
}

//&#x5F02;&#x6B65;&#x751F;&#x6210;&#x5668;&#xFF1A; Stream &#x3001; async* &#x3001; yield
Stream &lt;int&gt; getAsyncGenerator(int n) async* {
  int k = 0;
  while (k &lt; n) {
    yield k++;
  }
}

void main (){
  var it = getSyncGenerator(5).iterator;
  while (it.moveNext()) {
    print(it.current);
  }

  var stream =   getAsyncGenerator(5);
  // subscription.cancel();
  StreamSubscription subscription = stream.listen(null);
  subscription.onData( (value) {
    print(value);
  });
}

//  &#x7C7B;&#x7684; &#x7279;&#x6B8A;&#x51FD;&#x6570; call () &#x3002; &#x5B9E;&#x73B0;call()&#x65B9;&#x6CD5;&#x53EF;&#x4EE5;&#x8BA9;&#x4F60;&#x7684;Dart&#x7C7B;&#x50CF;&#x51FD;&#x6570;&#x4E00;&#x6837;&#x88AB;&#x8C03;&#x7528;&#x3002; &#x4E0D;&#x4E60;&#x60EF;&#x8FD9;&#x6837;&#x3002;&#x6682;&#x4EC5;&#x505A;&#x4E86;&#x89E3;&#x3002;
class Person {
  call(String a, String b ) {
   return  &apos;$a $b  &apos; ;
  }
}

main() {
  var person = new Person();
  var out = person(&quot;Hi&quot;, &quot;aivin&quot; );
  print(&apos;$out&apos;);
}


// &#x201C;&#x591A;&#x8FDB;&#x7A0B;&#x201D;&#x673A;&#x5236; Isolate
isolate&#x662F;Dart&#x5E73;&#x53F0;&#x5BF9;&#x7EBF;&#x7A0B;&#x7684;&#x5B9E;&#x73B0;&#x65B9;&#x6848;&#xFF0C;&#x4F46;&#x548C;&#x666E;&#x901A;Thread&#x4E0D;&#x540C;&#x7684;&#x662F;&#xFF0C;isolate&#x62E5;&#x6709;&#x72EC;&#x7ACB;&#x7684;&#x5185;&#x5B58;&#xFF0C;isolate&#x7531;&#x7EBF;&#x7A0B;&#x548C;&#x72EC;&#x7ACB;&#x5185;&#x5B58;&#x6784;&#x6210;&#x3002;
&#x7531;&#x4E8E;isolate&#x7EBF;&#x7A0B;&#x4E4B;&#x95F4;&#x7684;&#x5185;&#x5B58;&#x4E0D;&#x5171;&#x4EAB;&#xFF0C;&#x6240;&#x4EE5;isolate&#x7EBF;&#x7A0B;&#x4E4B;&#x95F4;&#x5E76;&#x4E0D;&#x5B58;&#x5728;&#x8D44;&#x6E90;&#x62A2;&#x593A;&#x7684;&#x95EE;&#x9898;&#xFF0C;&#x6240;&#x4EE5;&#x4E5F;&#x4E0D;&#x9700;&#x8981;&#x9501;&#x3002;
isolate&#x7EBF;&#x7A0B;&#x4E4B;&#x95F4;&#x7684;&#x901A;&#x4FE1;&#x4E3B;&#x8981;&#x901A;&#x8FC7;port&#x6765;&#x8FDB;&#x884C;&#xFF0C;&#x8FD9;&#x4E2A;port&#x6D88;&#x606F;&#x4F20;&#x9012;&#x7684;&#x8FC7;&#x7A0B;&#x662F;&#x5F02;&#x6B65;&#x7684;&#x3002;
isolate&#x770B;&#x8D77;&#x6765;&#x5176;&#x5B9E;&#x548C;&#x8FDB;&#x7A0B;&#x6BD4;&#x8F83;&#x76F8;&#x4F3C;&#xFF0C;&#x4E4B;&#x524D;&#x8BF7;&#x6559;&#x963F;&#x91CC;&#x67B6;&#x6784;&#x5E08;&#x5B97;&#x5FC3;&#x95EE;&#x9898;&#x65F6;&#xFF0C;
&#x5B97;&#x5FC3;&#x4E5F;&#x8BF4;&#x8FC7;&#x201C;isolate&#x7684;&#x6574;&#x4F53;&#x6A21;&#x578B;&#x6211;&#x81EA;&#x5DF1;&#x7684;&#x7406;&#x89E3;&#x5176;&#x5B9E;&#x66F4;&#x50CF;&#x8FDB;&#x7A0B;&#xFF0C;&#x800C;async&#x3001;await&#x66F4;&#x50CF;&#x662F;&#x7EBF;&#x7A0B;&#x201D;&#x3002;
&#x5982;&#x679C;&#x5BF9;&#x6BD4;&#x4E00;&#x4E0B;isolate&#x548C;&#x8FDB;&#x7A0B;&#x7684;&#x5B9A;&#x4E49;&#xFF0C;&#x4F1A;&#x53D1;&#x73B0;&#x786E;&#x5B9E;isolate&#x5F88;&#x50CF;&#x662F;&#x8FDB;&#x7A0B;&#x3002; &#xFF08;&#x8FD9;&#x6BB5;&#x8BDD;&#x6765;&#x81EA;&#x7F51;&#x7EDC;&#xFF0C;&#x6211;&#x6682;&#x65F6;&#x6CA1;&#x6709;&#x7528;&#x5230;&#x8FC7; Isolate &#xFF09;
</code></pre>
<pre><code class="lang-text">// &#x6784;&#x9020;&#x51FD;&#x6570;
class Point {
  num x, y;

  Point(num x, num y) {
    this.x = x;
    this.y = y;
  }
}

&#x53EF;&#x4EE5;&#x7B80;&#x5199;&#x6210; ---&gt; 
class Point {
  num x, y;

  Point(this.x, this.y); // &#x8BED;&#x6CD5;&#x7CD6;&#xFF0C;&#x6784;&#x9020;&#x51FD;&#x6570;&#x7684;&#x7B80;&#x5199;
}

---------------------------------------------------
class Point {
  num x, y;
  // &#x7C7B;&#x540D;&#x6784;&#x9020;&#x51FD;&#x6570;
  Point(this.x, this.y);
  // &#x547D;&#x540D;&#x6784;&#x9020;&#x51FD;&#x6570;
  Point.order(this.x,this.y);
  // &#x91CD;&#x5B9A;&#x5411;&#x6784;&#x9020;&#x51FD;&#x6570;&#xFF0C; origin&#x6784;&#x9020;&#x51FD;&#x6570;&#x5C06;&#x5916;&#x754C;&#x7684;&#x4F20;&#x503C;&#xFF0C;&#x6307;&#x5411;&#x7ED9;&#x4E86;order&#x6784;&#x9020;&#x51FD;&#x6570;&#x3002;
  Point.origin(num a,num b):this.order(a,b);  
}

---------------------------------------------------
class Person {
  String firstName;

  Person.fromJson(Map data) {
    print(&apos;in Person&apos;);
  }
}

class Employee extends Person {
  // &#x8C03;&#x7528;&#x7236;&#x7C7B;&#x6784;&#x9020;&#x51FD;&#x6570;&#xFF0C; &#x8BED;&#x6CD5;&#x4E0E;Java&#x4E0D;&#x4E00;&#x6837;&#x3002;
  // &#x5148;&#x6253;&#x5370;  in Person &#xFF0C; &#x540E;&#x6253;&#x5370;  in Employee
  Employee.fromJson(Map data) : super.fromJson(data) {
    print(&apos;in Employee&apos;);
  }
}

main() {
  var emp = new Employee.fromJson({});
}

// &#x968F;&#x673A;&#x6570;
weatherType = WeatherType.values[Random().nextInt(WeatherType.values.length)];

// =&gt; 
=&gt; expr &#x7B49;&#x540C;&#x4E8E;{ return expr; }
</code></pre>
<h2 id="&#x6CE8;&#x89E3;"><a name="&#x6CE8;&#x89E3;" class="anchor-navigation-ex-anchor" href="#&#x6CE8;&#x89E3;"><i class="fa fa-link" aria-hidden="true"></i></a>1.2. &#x6CE8;&#x89E3;</h2>
<pre><code class="lang-text">// immutable
&#x88AB; @immutable &#x6CE8;&#x89E3;&#x6807;&#x660E;&#x7684;&#x7C7B;&#x6216;&#x8005;&#x5B50;&#x7C7B;&#x90FD;&#x5FC5;&#x987B;&#x662F;&#x4E0D;&#x53EF;&#x53D8;&#x7684; .
</code></pre>
<footer class="page-footer"><span class="copyright">&#x65E0;&#x7248;&#x6743; &#x53EF;&#x4EE5;&#x65E0;&#x9650;&#x5236;&#x4F7F;&#x7528;&#xFF01; all right reserved&#xFF0C;powered by Gitbook</span><span class="footer-modification">&#x8BE5;&#x6587;&#x4EF6;&#x66F4;&#x65B0;&#x65F6;&#x95F4;&#xFF1A;
2020-11-16 08:13:17
</span></footer>
                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="flutter配置.html" class="navigation navigation-prev " aria-label="Previous page: flutter配置">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="flutter控件.html" class="navigation navigation-next " aria-label="Next page: flutter控件">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"flutter","level":"1.3","depth":1,"next":{"title":"flutter控件","level":"1.4","depth":1,"path":"chinese/flutter控件.md","ref":"chinese/flutter控件.md","articles":[]},"previous":{"title":"flutter配置","level":"1.2","depth":1,"path":"chinese/flutter配置.md","ref":"chinese/flutter配置.md","articles":[]},"dir":"ltr"},"config":{"plugins":["-search","search-plus","todo","anchor-navigation-ex","copy-code-button","fontsettings","tbfed-pagefooter","donate","local-video","splitter","favicon","theme-comscore","local-video"],"styles":{"website":"styles/website.css"},"pluginsConfig":{"tbfed-pagefooter":{"copyright":"无版权 可以无限制使用！","modify_label":"该文件更新时间：","modify_format":"YYYY-MM-DD HH:mm:ss"},"todo":{},"splitter":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"donate":{"alipay":"http://oyru0ayig.bkt.clouddn.com/201803011956_osChina_支付宝收款码.png","alipayText":"支付宝打赏","button":"打赏","title":"","wechat":"http://oyru0ayig.bkt.clouddn.com/201803011956_osChina_微信收款码.png","wechatText":"微信打赏"},"fontsettings":{"family":"sans","size":2,"theme":"sepia"},"highlight":{},"anchor-navigation-ex":{"associatedWithSummary":true,"float":{"floatIcon":"fa fa-navicon","level1Icon":"","level2Icon":"","level3Icon":"","showLevelIcon":false},"mode":"float","multipleH1":true,"pageTop":{"level1Icon":"","level2Icon":"","level3Icon":"","showLevelIcon":false},"printLog":false,"showGoTop":true,"showLevel":true},"favicon":{"shortcut":"assets/images/favicon.ico","bookmark":"assets/images/favicon.ico"},"theme-comscore":{},"local-video":{},"copy-code-button":{},"sharing":{"all":["facebook","google","twitter","weibo","instapaper"],"facebook":true,"google":false,"instapaper":false,"twitter":true,"vk":false,"weibo":false},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"search-plus":{}},"theme":"default","author":"Aivin","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"Aivin开发笔记","language":"zh-hans","gitbook":"*","description":"Aivin开发笔记"},"file":{"path":"chinese/flutter语法.md","mtime":"2020-11-16T00:13:17.796Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2020-12-01T08:13:35.355Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-search-plus/jquery.mark.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search-plus/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-copy-code-button/toggle.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-donate/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-local-video/video.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-splitter/splitter.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-theme-comscore/test.js"></script>
        
    

    </body>
</html>

